package iedcyt.acute.controller;

import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Listener;

import iedcyt.acute.controller.listeners.configuration.*;
import iedcyt.acute.model.ConfigurationModel;
import iedcyt.acute.view.ConfigurationView;

public class ConfigurationController {

	private ConfigurationView _view;
	private ConfigurationModel _model;
	
	public ConfigurationController(ConfigurationView view) {
		_view = view;
		_model = new ConfigurationModel();
	}
	
	public void iniView() {
		_model.setChanged(false);
		_view.SetContentOfTable(_model.getProperties());
		_view.moveLocalShellToCenter();
		_view.openWindow();
	}
	
	public RowModifyListener getRowModifyListener(TableEditor editor, String key) {
		RowModifyListener modL = new RowModifyListener(_view, _model);
		modL.setEditor(editor);
		modL.setKey(key);
		return modL;
	}

	public Listener getCloseListener() {
		return new CloseListener(_view, _model);
	}
	
	public DisposeListener getCloseAndDisposeListener() {
		return new SaveListener(_view, _model);
	}

}
